﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using CARMSBusiness;
using CARMSBusiness.InterFace;
using CARMSData.EntityClasses;

namespace CARMS
{
    public class MessageFunction : PageBase
    {
        public void SendGroupMessageCertificateToCreatePDF(Guid jobID)
        {
            //var jobEntity = new JobEntity(jobID);

            //var messageTemplate = new VelocityHelper(Server.MapPath("~/MessageTemplate"));
            //messageTemplate.Variables.Add("jobNumber", jobEntity.JobNumber);

            //var strContent = messageTemplate.GetContent("ResultToCreatePDF.htm");

            //var message = new GroupMessageEntity
            //                  {
            //                      Title = "To Create Certificate PDF",
            //                      JobId = jobID,
            //                      DepartmentId = DictionaryCategoryConst.DepartmentList.Administration,
            //                      PositionId = DictionaryCategoryConst.DepartmentPosition.Typist,
            //                      ActionUrl =
            //                          SiteUrls.JobInfo.MyJobAdmin + "?JobID=" + jobEntity.JobId,
            //                      MessageContent = strContent,
            //                      MessageType = DictionaryCategoryConst.MessageType.CertificateFlow
            //                  };
            //MessageBusiness.DeleteGroupMessage(jobID, DictionaryCategoryConst.DepartmentList.Administration,
            //                                   DictionaryCategoryConst.DepartmentPosition.Typist);
            //MessageBusiness.SendGroupMessage(message);
        }

        public void SendGroupMessageCertificateToResultSender(Guid jobID)
        {
            //var jobEntity = new JobEntity(jobID);

            //var messageTemplate = new VelocityHelper(Server.MapPath("~/MessageTemplate"));
            //messageTemplate.Variables.Add("jobNumber", jobEntity.JobNumber);

            //var strContent = messageTemplate.GetContent("ResultToSendToClient.htm");

            //var message = new GroupMessageEntity
            //{
            //    Title = "To Send Certificate to Client",
            //    JobId = jobID,
            //    DepartmentId = DictionaryCategoryConst.DepartmentList.Administration,
            //    PositionId = DictionaryCategoryConst.DepartmentPosition.Diplomat,
            //    ActionUrl =
            //        SiteUrls.JobInfo.MyJobAdmin + "?JobID=" + jobEntity.JobId,
            //    MessageContent = strContent,
            //    MessageType = DictionaryCategoryConst.MessageType.CertificateFlow
            //};

            //MessageBusiness.DeleteGroupMessage(jobID, DictionaryCategoryConst.DepartmentList.Administration,
            //                                   DictionaryCategoryConst.DepartmentPosition.Diplomat);
            //MessageBusiness.SendGroupMessage(message);

        }


        //public void SendGroupMessageReportToDoTyping(Guid jobID)
        //{
        //    var jobEntity = new JobEntity(jobID);

        //    var messageTemplate = new VelocityHelper(Server.MapPath("~/MessageTemplate"));
        //    messageTemplate.Variables.Add("jobNumber", jobEntity.JobNumber);

        //    var strContent = messageTemplate.GetContent("ReportToDoType.htm");

        //    var message = new GroupMessageEntity
        //    {
        //        Title = "To Type Report",
        //        JobId = jobID,
        //        DepartmentId = DictionaryCategoryConst.DepartmentList.Administration,
        //        PositionId = DictionaryCategoryConst.DepartmentPosition.Typist,
        //        ActionUrl =
        //            SiteUrls.JobInfo.MyJobAdmin + "?JobID=" + jobEntity.JobId,
        //        MessageContent = strContent,
        //        MessageType = DictionaryCategoryConst.MessageType.CertificateFlow
        //    };

        //    MessageBusiness.DeleteGroupMessage(jobID, DictionaryCategoryConst.DepartmentList.Administration,
        //                           DictionaryCategoryConst.DepartmentPosition.Typist);
        //    MessageBusiness.SendGroupMessage(message);
        //}


        //public void SendMessageReportToTDMApprove(Guid jobID)
        //{
        //    var jobEntity = new JobEntity(jobID);
        //    var quotation = JobBusiness.GetQuotationByJobID(jobID);
        //    var strTDMName = DepartmentBusiness.GetEmployeeNameByID(quotation.TdmemployeeId);
        //    var messageTemplate = new VelocityHelper(Server.MapPath("~/MessageTemplate"));
        //    messageTemplate.Variables.Add("jobNumber", jobEntity.JobNumber);
        //    messageTemplate.Variables.Add("tdmName", strTDMName);
            
        //    var strContent = messageTemplate.GetContent("ReportToTDMToApprove.htm");

        //    var message = new MessageEntity
        //    {
        //        Title = "To Approve Typed Report ",
        //        JobId = jobID,
        //        EmployeeId = quotation.TdmemployeeId,
        //        ActionUrl =
        //            SiteUrls.JobInfo.MyJob + "?JobID=" + jobEntity.JobId,
        //        MessageContent = strContent,
        //        MessageType = DictionaryCategoryConst.MessageType.CertificateFlow
        //    }; 
             
        //    MessageBusiness.DeleteGroupMessage(jobID, DictionaryCategoryConst.DepartmentList.Administration,
        //                           DictionaryCategoryConst.DepartmentPosition.Typist);
        //    MessageBusiness.CreateNormalMessage(message);
        //}


        //public void SendGroupMessageReportToScan(Guid jobID)
        //{
        //    var jobEntity = new JobEntity(jobID);

        //    var messageTemplate = new VelocityHelper(Server.MapPath("~/MessageTemplate"));
        //    messageTemplate.Variables.Add("jobNumber", jobEntity.JobNumber);

        //    var strContent = messageTemplate.GetContent("ReportToScan.htm");

        //    var message = new GroupMessageEntity
        //    {
        //        Title = "To Scan and Upload Approved Report by TDM",
        //        JobId = jobID,
        //        DepartmentId = DictionaryCategoryConst.DepartmentList.Administration,
        //        PositionId = DictionaryCategoryConst.DepartmentPosition.Clerk,
        //        ActionUrl =
        //            SiteUrls.JobInfo.MyJobAdmin + "?JobID=" + jobEntity.JobId,
        //        MessageContent = strContent,
        //        MessageType = DictionaryCategoryConst.MessageType.CertificateFlow
        //    };
        //    //tdm approved report ，then to upload the approved report
        //    MessageBusiness.DeleteMessage(jobID, DictionaryCategoryConst.MessageType.CertificateFlow);
        //    MessageBusiness.SendGroupMessage(message);
        //}

        //public void SendGroupMessageReportToSendToClient(Guid jobID)
        //{
        //    var jobEntity = new JobEntity(jobID);

        //    var messageTemplate = new VelocityHelper(Server.MapPath("~/MessageTemplate"));
        //    messageTemplate.Variables.Add("jobNumber", jobEntity.JobNumber);

        //    var strContent = messageTemplate.GetContent("ReportToSendToClient.htm");

        //    var message = new GroupMessageEntity
        //    {
        //        Title = "To Send Report to Client",
        //        JobId = jobID,
        //        DepartmentId = DictionaryCategoryConst.DepartmentList.Administration,
        //        PositionId = DictionaryCategoryConst.DepartmentPosition.Diplomat,
        //        ActionUrl =
        //            SiteUrls.JobInfo.MyJobAdmin + "?JobID=" + jobEntity.JobId,
        //        MessageContent = strContent,
        //        MessageType = DictionaryCategoryConst.MessageType.CertificateFlow
        //    };
        //    //删除to upload report 的message
        //    MessageBusiness.DeleteGroupMessage(jobID, DictionaryCategoryConst.DepartmentList.Administration,
        //                         DictionaryCategoryConst.DepartmentPosition.Clerk);
        //    MessageBusiness.SendGroupMessage(message);
        //}



        //public void SendGroupMessageInvoiceToDo(Guid jobID)
        //{
        //    var jobEntity = new JobEntity(jobID);

        //    var messageTemplate = new VelocityHelper(Server.MapPath("~/MessageTemplate"));
        //    messageTemplate.Variables.Add("jobNumber", jobEntity.JobNumber);

        //    var strContent = messageTemplate.GetContent("InvoiceToDo.htm");

        //    var message = new GroupMessageEntity
        //    {
        //        Title = "To Make Invoice",
        //        JobId = jobID,
        //        DepartmentId = DictionaryCategoryConst.DepartmentList.Administration,
        //        PositionId = DictionaryCategoryConst.DepartmentPosition.Accouting,
        //        ActionUrl =
        //            SiteUrls.JobInfo.MyJobAdmin + "?JobID=" + jobEntity.JobId,
        //        MessageContent = strContent,
        //        MessageType = DictionaryCategoryConst.MessageType.CertificateFlow
        //    };
        //    //删除to upload report 的message
        //    MessageBusiness.DeleteGroupMessage(jobID, DictionaryCategoryConst.DepartmentList.Administration,
        //                       DictionaryCategoryConst.DepartmentPosition.Clerk);

        //    MessageBusiness.SendGroupMessage(message);
        //}


        //public void SendGroupMessageJobToClose(Guid jobID)
        //{
        //    var jobEntity = new JobEntity(jobID);

        //    var messageTemplate = new VelocityHelper(Server.MapPath("~/MessageTemplate"));
        //    messageTemplate.Variables.Add("jobNumber", jobEntity.JobNumber);

        //    var strContent = messageTemplate.GetContent("JobToClose.htm");

        //    var message = new MessageEntity
        //    {
        //        Title = "To Confirm Payment Received, Close Job",
        //        JobId = jobID,
        //        EmployeeId = GetEmployeeID(jobEntity.CreateUserId),
        //        ActionUrl =
        //            SiteUrls.JobInfo.MyJobAdmin + "?JobID=" + jobEntity.JobId,
        //        MessageContent = strContent,
        //        MessageType = DictionaryCategoryConst.MessageType.CertificateFlow
        //    };

        //    //删除to send report to client  和 do invoicing 的消息
        //    MessageBusiness.DeleteGroupMessage(jobID, DictionaryCategoryConst.DepartmentList.Administration,
        //              DictionaryCategoryConst.DepartmentPosition.Accouting);
        //    MessageBusiness.DeleteGroupMessage(jobID, DictionaryCategoryConst.DepartmentList.Administration,
        //           DictionaryCategoryConst.DepartmentPosition.Diplomat);
        //    MessageBusiness.CreateNormalMessage(message);
        //}



    }
}
